package timer;

import org.springframework.util.CollectionUtils;
import java.util.List;
import java.util.Timer;
import java.util.TimerTask;
import entity.Users;

/**
 * Created by wuzhao on 2017/4/5 0005.
 */
public class HashWheelTimerTest {

    class SubTask extends TimerTask {

        @Override
        public void run() {
            System.out.println("===timer.HashWheelTimerTest.SubTask.run");
            List<Users> users = TimerTaskEntity.moveTask();
            if (!CollectionUtils.isEmpty(users)){
                System.out.println("===任务长度:"+users.size());
            }else {
                System.out.println("===没有任务");
            }
        }
    }

    public void repeatTask(){
        TimerTaskEntity.addTask(4,new Users("id","name"));
        Timer timer = new Timer();
        timer.scheduleAtFixedRate(new SubTask(),0,1*1000);
    }

    public static void main(String[] args) {

        HashWheelTimerTest hashWheelTimerTest = new HashWheelTimerTest();
        hashWheelTimerTest.repeatTask();
    }

}
